import { fetch } from '@/utils/fetch.js';

export function goodsInsert(params) {
  return fetch({
    url: '/questionlib/nice/goods/insert',
    method: 'POST',
    data: params,
  });
}
// 获取商品详情
export function queryGoodsById(params) {
  return fetch({
    url: '/usercenter/operation/goods/queryGoodsById',
    method: 'POST',
    data: params,
  });
}

// 更新商品
export function goodsUpdate(params) {
  return fetch({
    url: '/questionlib/nice/goods/update',
    method: 'POST',
    data: params,
  });
}

// 获取商品原价
export function getGoodsPrice(params) {
  return fetch({
    url: '/usercenter/operation/goods/price',
    method: 'POST',
    data: params,
  });
}

// 删除商品
export function goodsDelete(params) {
  return fetch({
    url: '/usercenter/operation/goods/delete',
    method: 'POST',
    data: params,
  });
}

// 获取课程最早的上课时间
export function courseEarliest(params) {
  return fetch({
    url: '/questionlib/nice/course/earliest',
    method: 'POST',
    data: params,
  });
}
// 获取课程最晚的上课时间L
export function courseLatest(params) {
  return fetch({
    url: '/questionlib/nice/course/latest',
    method: 'POST',
    data: params,
  });
}

// 商品上架
export function goodsIn(params) {
  return fetch({
    url: '/usercenter/operation/goods/list',
    method: 'POST',
    data: params,
  });
}
// 商品下架
export function goodsOut(params) {
  return fetch({
    url: '/usercenter/operation/goods/delist',
    method: 'POST',
    data: params,
  });
}

//金币商城
//获取兑换商品列表(含分页)
export function getGoodList(params) {
  let { pageNum, size } = params;
  let arg = {
    goodsName: params.goodsName,
    status: params.status,
  };
  return fetch({
    url: `/nice/physical/goods/list/${pageNum}/${size}`,
    method: 'POST',
    data: arg,
  });
}

//添加兑换商品
export function addGood(params) {
  return fetch({
    url: '/questionlib/nice/physical/goods/add',
    method: 'POST',
    data: params,
  });
}

//获取指定的兑换商品
export function getGoodById(params) {
  return fetch({
    url: `/nice/physical/target/goods/${params.id}`,
    method: 'GET',
    data: {},
  });
}

//更新商品信息
export function updateGood(params) {
  return fetch({
    url: '/questionlib/nice/physical/target/goods/update',
    method: 'POST',
    data: params,
  });
}

//上下架状态更新
export function updateGoodStatus(params) {
  return fetch({
    url: `/nice/physical/goods/status/update/${params.good_id}/${params.status}`,
    method: 'GET',
    data: {},
  });
}

//商品数据导出
export function exportGood(params) {
  return fetch({
    url: '/questionlib/nice/physical/goods/list/export',
    method: 'POST',
    data: params,
    responseType: 'blob',
  });
}
